const CHARACTER: [char; 16] = [
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
];
pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let left_bracket = num_str.find('(').unwrap();
    let right_bracket = num_str.find(')').unwrap();
    let num = num_str[0..left_bracket].to_owned();
    let from_base = num_str[left_bracket + 1..right_bracket]
        .parse::<u32>()
        .unwrap();
    let mut remain_len = num.len() as u32;
    let mut num_val = 0;
    num.chars().for_each(|ch| {
        remain_len -= 1;
        match ch {
            '0'..='9' => {
                num_val += (ch as u32 - 48) * from_base.pow(remain_len);
            }
            'a'..='f' => {
                num_val += (ch as u32 - 97 + 10) * from_base.pow(remain_len);
            }
            _ => unreachable!(),
        }
    });
    // println!("{num_val}");
    if num_val == 0 {
        return "0".to_string();
    }
    let mut ans: Vec<char> = vec![];
    while num_val != 0 {
        ans.push(CHARACTER[(num_val % to_base) as usize]);
        num_val /= to_base;
    }
    ans.iter().rev().collect()
}
